﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data;
using System.Data.OleDb;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

public partial class Plan_Simple : UserControl
{

    #region Members
    private string _strDate = "";
    public string StrDate
    {
        get { return _strDate; }
        set { _strDate = value; }
    }
    private string sql =
@"
SELECT 
      [Дата]
    , [Магазин]
    , [Мебель]
    , [Одежда]
    , [Обувь]
    , [Игрушки]
    , [Детское питание] AS Детское_питание
    , [Косметика]
    , [Подгузники]
    , [Год]
    , [Месяц] 
FROM [vw_a_Plan_2]
";
    #endregion Members

    protected void Page_Load(object sender, EventArgs e)
    {
        if (oData.SelectedIndex >= 0)
        {
            StrDate = oData.SelectedValue;
            DSPlan.SelectCommand = sql
                + " WHERE (Дата = '" + oData.SelectedValue + "') ";
            if (oRegion.Checked)
                DSPlan.SelectCommand += " AND (Регион = N'" + oData2.Text + "')";
        }
        else
        {
            StrDate = "";
            DSPlan.SelectCommand = "";
        }
        gv.DataBind();
    }

    protected void gw_DataBound(object sender, EventArgs e)
    {
        if (gv.SelectedIndex >= 0)
            RefreshDetals(gv.Rows[gv.SelectedIndex].Cells[1].Text);
        else
            RefreshDetals("");
    }

    private void RefreshDetals(string strDate)
    {
    }

    protected void oData_SelectedIndexChanged(object sender, EventArgs e)
    {
        gv.SelectedIndex = -1;
    }

    protected void gv_SelectedIndexChanged(object sender, EventArgs e)
    {

    }

}

